package com.srd.phone.bean;

import org.json.JSONException;
import org.json.JSONObject;

public class UserInfo {

    public String userName;
    public String pwd;
    public int count;
    public int code;
    public String msg;
    public String token;
    public String uid;
    public String email;
    public String rid;
    public String phone;
    public String ticket;
    public int baseCount = 3;
    public int failed;
    public String src;

    public String available;
    public String frozenfund;
    public String order;
    public String penmoney;
    public String scRecord;
    public String sinves;
    public String sprofit;
    public String sumreco;
    public String total;

    public static UserInfo parse(String json) {
        UserInfo info = new UserInfo();
        try {
            JSONObject jsonObject = new JSONObject(json);
            info.count = jsonObject.optInt("count");
            info.code = jsonObject.optInt("code");
            info.msg = jsonObject.optString("msg");
            info.token = jsonObject.optString("token");
            JSONObject jsonObject2 = jsonObject.getJSONObject("data");
            info.uid = jsonObject2.optString("uid");
            info.email = jsonObject2.optString("email");
            info.rid = jsonObject2.optString("rid");
            info.phone = jsonObject2.optString("phone");
            info.ticket = jsonObject2.optString("ticket");
            info.baseCount = jsonObject2.optInt("baseCount");
            info.failed = jsonObject2.optInt("failed");
            info.src = jsonObject2.optString("src");

            JSONObject jsonAccount = jsonObject.getJSONObject("myAccount");
            info.available = jsonAccount.optString("available");
            info.frozenfund = jsonAccount.optString("frozenfund");
            info.penmoney = jsonAccount.optString("penmoney");
            info.scRecord = jsonAccount.optString("scRecord");
            info.sinves = jsonAccount.optString("sinves");
            info.sprofit = jsonAccount.optString("sprofit");
            info.sumreco = jsonAccount.optString("sumreco");
            info.total = jsonAccount.optString("total");
            info.order = jsonAccount.optString("order");

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return info;
    }

}
